package com.tpyule.tpclass.service.impl;

import com.tpyule.tpclass.dao.StudiedDao;
import com.tpyule.tpclass.entity.pojo.Studied;
import com.tpyule.tpclass.service.StudiedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @author zzz
 * @version 1.0
 * @date 2020/4/16 16:43
 */
@Service
public class StudiedServiceImpl implements StudiedService {
    @Autowired
    StudiedDao studiedDao;
    @Override
    public int addStudied(Studied studied) {
        int result = -1;
        if(studied!=null){
            studied.setStudiedId(UUID.randomUUID().toString().toUpperCase());
            result = studiedDao.addStudied(studied);
        }
        return result;
    }

    @Override
    public int updateStudied(Studied studied) {
        int result = -1;
        if(studied!=null){
            result = studiedDao.updateStudied(studied);
        }
        return result;
    }

    @Override
    public Studied getLastStudied(String userId, String courseId) {
        return studiedDao.getLastStudied(userId,courseId);
    }

    @Override
    public Studied getStudiedBySU(String userId, String sectionId) {
        return studiedDao.getStudiedBySU(userId, sectionId);
    }
}
